﻿<UserControl x:Class="Assembly.Metro.Controls.PageTemplates.Games.Components.Editors.LocaleEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Editors="clr-namespace:Assembly.Metro.Controls.PageTemplates.Games.Components.Editors"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="1000">
    <Grid>
        <!--<Border Height="35" VerticalAlignment="Top" BorderThickness="0,1,0,0" BorderBrush="#434346" Background="#FF303032">
            <StackPanel Margin="10,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
                <TextBlock Text="Language: " Style="{DynamicResource GenericTextblock}" />
                <ComboBox x:Name="cbLanguages" ItemsSource="{Binding}" Width="175" Margin="10,0,0,0" SelectionChanged="cbLanguages_SelectionChanged">
                    <ComboBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" />
                        </ItemsPanelTemplate>
                    </ComboBox.ItemsPanel>
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Language}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </StackPanel>
        </Border>-->
        <DataGrid x:Name="lvLocales" ItemsSource="{Binding}" Background="{x:Null}" Margin="0,0,0,35" Padding="0" BorderThickness="0" Foreground="White" VerticalAlignment="Stretch" SelectionChanged="lvLocales_SelectionChanged"
                  VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" AutoGenerateColumns="False" GridLinesVisibility="None" RowHeaderWidth="0" HeadersVisibility="Column"
                  CanUserAddRows="False">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Index" Binding="{Binding Index}" Width="55" IsReadOnly="True" />
                <DataGridTextColumn Header="Locale" Binding="{Binding Locale}" Width="*">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="TextWrapping" Value="Wrap" />
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                    <DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
                            <Setter Property="Height" Value="Auto" />
                            <Setter Property="TextWrapping" Value="Wrap" />
                        </Style>
                    </DataGridTextColumn.EditingElementStyle>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
        <Border Height="35" VerticalAlignment="Bottom" BorderThickness="0,1,0,0" BorderBrush="#434346" Background="#FF303032">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="210" />
                </Grid.ColumnDefinitions>
                <Button x:Name="btnSaveAll" Grid.Column="0" Content="Save All" Width="72" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0" Click="btnSaveAll_Click" />

                <!-- I tried real-time searching (with a text-changed, so laggy)  -->
                <Grid Grid.Column="0" Margin="100,0,10,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="50" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="60" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="Filter:" Grid.Column="0" Margin="0,0,0,0" Style="{DynamicResource GenericTextblock}" VerticalAlignment="Center" HorizontalAlignment="Left" />
                    <TextBox x:Name="txtFilter" Grid.Column="1" Margin="0,0,5,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" KeyDown="txtFilter_KeyDown"  />
                    
                    <Button x:Name="btnFilter" Content="Filter" Grid.Column="2" Click="btnFilter_Click" />
                </Grid>
                
                <TextBlock Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0" Text="Double-click on a locale to edit it." Style="{DynamicResource GenericTextblock}" />
            </Grid>
        </Border>
    </Grid>
</UserControl>
